functor
import
   Tk Browser Pickle Application
define
%   F={New Tk.font tkInit(family:tahoma weight:normal size:10)}

   W={New Tk.toplevel tkInit}

   fun {Fact N}
      if N =< 1 then 1 
      else N * {Fact N-1} end
   end

   fun {Fib N}
      if N =< 1 then 1
      else {Fib N-1} + {Fib N-2} end
   end

   B1={New Tk.button tkInit(parent: W
                            text: "Save fact!"
                            action: proc {$}  
                                       {Pickle.saveWithHeader Fact 'fact.pcl' 'Funkcija fact' 0}
                                    end)}
 

   B2={New Tk.button tkInit(parent: W
                            text: "Save fib!"
                            action: proc {$}  
                                       {Pickle.saveWithHeader Fib 'fact.pcl' 'Funkcija fib' 0}
                                    end)}
 


   B3={New Tk.button tkInit(parent: W
                            text: "Load func"
                            action: proc {$}
                                       F Header
                                    in
                                       Header#F={Pickle.loadWithHeader 'fact.pcl'}
                                       {Browser.browse Header#{F 5}}
                                    end)}

   proc {OnClose}
      {W tkClose}
      {Application.exit 0}
   end

   B4={New Tk.button tkInit(parent: W
                            bitmap: error
                            action: OnClose)}

   {Tk.send pack(B1 B2 B3 B4 fill:x padx:1#m pady:1#m)}


end
